package com.fastCms.manager.frame.controller;


import com.fastCms.business.frame.busi.CloudOrganizeManageService;
import com.fastCms.business.frame.pojo.PageParam;
import com.fastCms.business.frame.pojo.entity.CloudOrganize;
import com.fastCms.business.frame.pojo.po.EditOrganizeStatusPO;
import com.fastCms.business.frame.pojo.po.QueryOrganizePO;
import com.fastCms.business.frame.pojo.vo.CloudOrganizePO;
import com.fastCms.business.frame.response.ApiResponse;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * <p>
 * 平台组织结构表 前端控制器
 * </p>
 *
 * @author liusq
 * @since 2019-05-26
 */
@RestController
@RequestMapping("/cloudOrganize")
@Api(value = "CloudOrganizeController", tags = "后端-组织管理")
public class CloudOrganizeController {
    @Autowired
    private CloudOrganizeManageService cloudOrganizeManageServiceImpl;

    @ApiOperation(value = "创建新的入驻组织(运营企业)")
    @PostMapping(value = "/createOrganize")
    public ApiResponse createOrganize(@RequestBody @Valid CloudOrganizePO organizePO) {
        ApiResponse result = cloudOrganizeManageServiceImpl.createOrganize(organizePO);
        return result;
    }

    @ApiOperation(value = "查询组织列表(运营企业)", notes = "根据当前组织code查询子组织")
    @PostMapping(value = "/showOrganizes")
    public ApiResponse<PageInfo<CloudOrganize>> showOrganizes(@RequestBody PageParam<QueryOrganizePO> queryOrganizePO) {
        ApiResponse result = cloudOrganizeManageServiceImpl.showOrganizes(queryOrganizePO);
        return result;
    }

    @ApiOperation(value = "编辑组织信息", notes = "编辑组织信息-不可修改手机号码")
    @PostMapping(value = "/editOrganize")
    public ApiResponse<CloudOrganize> editOrganize(@RequestBody @Valid CloudOrganizePO cloudOrganizePO) {
        ApiResponse result = cloudOrganizeManageServiceImpl.editOrganize(cloudOrganizePO);
        return result;
    }


    @ApiOperation(value = "修改组织状态(运营企业)", notes = "修改组织状态")
    @PostMapping(value = "/editOrganizeStatus")
    public ApiResponse<Boolean> editOrganizeStatus(@RequestBody @Valid EditOrganizeStatusPO statusPO) {
        ApiResponse result = cloudOrganizeManageServiceImpl.editOrganizeStatus(statusPO);
        return result;
    }
}

